package com.dj.msgtable.dao;

import com.dj.msgtable.entity.Custom;
import com.dj.msgtable.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CustomMapper {


    @Select("Select * From custom ORDER BY `inputTime` DESC")
    List<Custom> searchAllCustom();

    @Select("Select * From custom where phone = #{phone}")
    Custom searchCustombyPhone(Custom custom);



    @Insert("insert into custom (realName,platform,origin,account,phone,qq,remarks,url,keyword,resourceForm,project,area,inputTime,status) value ( #{realName},#{platform},#{origin},#{account},#{phone},#{qq},#{remarks},#{url},#{keyword},#{resourceForm},#{project},#{area},#{inputTime},#{status})")
    void addCustomNof(Custom custom);

    @Insert("insert into custom (realName,platform,origin,account,phone,qq,remarks,url,keyword,resourceForm,project,area,inputTime,status,followUser) value ( #{realName},#{platform},#{origin},#{account},#{phone},#{qq},#{remarks},#{url},#{keyword},#{resourceForm},#{project},#{area},#{inputTime},#{status},#{followUser})")
    void addCustomHavef(Custom custom);

    @Select("Select * From custom where followUser is null")
    List<Custom> searchCustomNoFollow();


    @Update("UPDATE custom SET followUser = #{followUser} WHERE id = #{id}")
    void addFollowUser(Custom custom);

    @Select("Select * From custom where followUser = #{id} ORDER BY `inputTime` DESC")
    List<Custom> searchSelfList(User user);

    @Update("UPDATE custom SET keyword=#{keyword} , area = #{area}, isable = #{isable} , label = #{label} WHERE id = #{id}")
    void changeState(Custom custom);


    @Select("Select * From custom where id = #{id}")
    Custom searchOne(Custom custom);


    @Update("UPDATE custom SET isable = #{isable} WHERE id = #{id}")
    void changeState2(Custom custom);

    @Delete("delete from custom where 1=1")
    int deleteCus();
//    ORDER BY `inputTime` DESC
}
